
*****	Figures 3, 4, and 5	  *****
	
	use "PakPrepAnalysis_wide.dta", clear
		
	label var sc_tv "TV"
	label var sc_radio "Radio" 
	label var sc_online "Online"
	
// Figure 3
	statplot sc_online sc_tv sc_radio [aw=weight], recast(bar) ytitle("Percentage of households") over(q) asyvars // blabel(bar, position(outside) format(%3.2f)) - for inspecting exact figures
	
// stats on use of remote learning modalities
	tabstat sc_online sc_tv sc_radio [aw=weight]
	tabstat sc_online sc_tv sc_radio [aw=weight], by(q)
	
	rename sc_online_rating rating_online
	rename sc_tv_rating rating_tv
	reshape long rating, i(caseid_e) j(remote_type) string
	
	replace remote_type = "Online" if remote_type == "_online"
	replace remote_type = "TV" if remote_type == "_tv"
	
// Figure 5
	catplot rating [aw=weight], over(remote_type) percent(remote_type) asyvars l1title("Rating") // blabel(bar, position(outside) format(%3.2f)) - for inspecting exact figures
	
	reshape wide
	
	foreach sex in boys girls{
		label var sc_other_`sex'_none "Nothing"
		label var sc_other_`sex'_tutor "Hired private tutor"
		label var sc_other_`sex'_parents "Parents helped"
		label var sc_other_`sex'_na "Not applicable"
		label var sc_other_`sex'_siblings "Siblings helped"
		label var sc_other_`sex'_internet "Bought more internet access"
		label var sc_other_`sex'_online_paid "Bought online resources"
		label var sc_other_`sex'_books "Bought books"
	}
	
	gen no_learning_arr_boys = 0 if sc_tv == 100 | sc_radio == 100 | sc_online == 100 | sc_other_boys_none == 0
	replace no_learning_arr_boys = 100 if sc_tv == 0 & sc_radio == 0 & sc_online == 0 & sc_other_boys_none == 100
	
	gen no_learning_arr_girls = 0 if sc_tv == 100 | sc_radio == 100 | sc_online == 100 | sc_other_girls_none == 0
	replace no_learning_arr_girls = 100 if sc_tv == 0 & sc_radio == 0 & sc_online == 0 & sc_other_girls_none == 100
	
	gen no_learning_arr = 0
	replace no_learning_arr = 100 if (no_learning_arr_boys == 100 & no_learning_arr_girls == 100) | (no_learning_arr_boys == 100 & sc_other_girls_na == 100) | (no_learning_arr_girls == 100 & sc_other_boys_na == 100)
	
	label var sc_tv "TV"
	label var sc_online "Online"
	label var sc_radio "Radio"
	label var no_learning_arr_boys "None"
	label var no_learning_arr_girls "None"
	
	gen sc_other_tutor = 0
	replace sc_other_tutor = 100 if sc_other_boys_tutor == 100 | sc_other_girls_tutor == 100
	
	gen sc_other_parents = 0
	replace sc_other_parents = 100 if sc_other_boys_parents == 100 | sc_other_girls_parents == 100
	
	gen sc_other_siblings = 0
	replace sc_other_siblings = 100 if sc_other_boys_siblings == 100 | sc_other_girls_siblings == 100
	
	label var no_learning_arr "No learning arrangements"
	label var sc_other_tutor "Tutor"
	label var sc_other_parents "Parents"
	label var sc_other_siblings "Siblings"
	
	statplot no_learning_arr sc_other_tutor sc_other_parents sc_online sc_other_siblings sc_tv sc_radio [aw=weight], b1title("Percentage") by(q) ytitle(" ")
	
	ren (no_learning_arr sc_other_tutor sc_other_parents sc_online sc_other_siblings sc_tv sc_radio) (var_no_learning_arr var_sc_other_tutor var_sc_other_parents var_sc_online var_sc_other_siblings var_sc_tv var_sc_radio)
	
	reshape long var_, i(caseid_e) j(variable, string)
	
	replace var_ = . if var_ == 0
	label define var_label 100 "|" 1 "|"
	label values var_ var_label
	
	replace variable = "No arrangements" if variable == "no_learning_arr"
	replace variable = "Online" if variable == "sc_online"
	replace variable = "Parents helped" if variable == "sc_other_parents"
	replace variable = "Siblings helped" if variable == "sc_other_siblings"
	replace variable = "Radio" if variable == "sc_radio"
	replace variable = "TV" if variable == "sc_tv"
	replace variable = "Tutor" if variable == "sc_other_tutor"
	
	label define order  1 "No arrangements" 2 "Tutor" 3 "Parents helped" 4 "Online"  5 "Siblings helped" 6 "TV"  7 "Radio"
	encode variable, gen(variable1) label(order)
	
	graph bar var_ [aw=weight], over(variable1) // over(q) stack
	
	graph hbar q?, over(variable1,sort(q4)descending) over(var_) stack
	
	
******	Figures 2 and 6	*******

	use "PakPrepAnalysis_long.dta", clear
	
	gen age_pre_covid = age_post_covid - 2

	// statistics on enrollment before and after covid
	tab enrolled_pre_covid [aw=weight] if age_pre_covid >= 6 & age_pre_covid <=16
	tab enrolled_post_covid [aw=weight] if age_post_covid >= 6 & age_post_covid <= 16
	
	reshape long age_ enrolled_, i(caseid_e child) j(time) string
	drop if time == "other_child"

	replace time = "pre-COVID" if time == "pre_covid"
	replace time = "post-COVID" if time == "post_covid"
	label define order 1 "pre-COVID" 2 "post-COVID"
	encode time, gen(time1) label(order)
	
	replace enrolled = enrolled * 100
	
	ren age_ age
	ren enrolled_ enrolled
	
	gen age_cat = 1 if age >= 7 & age <= 10
	replace age_cat = 2 if age >=11 & age <= 13
	replace age_cat = 3 if age >=14 & age <= 16
	replace age_cat = 4 if age >=17 & age <= 18
	
	label define age_cat_lab 1 "7-10" 2 "11-13" 3 "14-16" 4 "17-18", replace
	
	label val age_cat age_cat_lab
	
// Figure 2
	graph bar enrolled [aw=weight] if age > 6 & age <17, over(time1) over(age_cat) over(q) asyvars b1title(Age) ytitle(Percentage enrolled) // blabel(bar, position(outside) format(%3.2f)) - for inspecting exact figures
	
	use "PakPrepAnalysis_long.dta", clear

	gen grade_change = grade_post_covid - grade_pre_covid
	replace grade_change = . if grade_change < -1 | grade_change > 2
	
// Figure 6	
	catplot grade_change [aw=weight], recast(bar) ytitle("Percentage") percent b1title("Grades progressed since March 2020") // blabel(bar, position(outside) format(%3.2f)) - for inspecting exact figures

	replace days_pw = . if days_pw < 0
	
// Figure 7	
	graph bar [aw=weight], over(days_pw) ytitle("Percentage") b1title("Days per week attending school")
